home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 March: Reference Library / Dev.CD Mar 97 RL.toast / mac / Technical Documentation / develop / develop Issue 24 / develop Issue 24 code / Scriptable Database 1.0a15.sea / Scriptable Database 1.0a15 / Blue / ThreadContext.h / ThreadContext.h
Encoding:
C/C++ Source or Header  |  1996-02-20  |  1.2 KB  |  50 lines  |  [TEXT/CWIE]

  1.  
  2. #ifndef __THREADCONTEXT__
  3. #define __THREADCONTEXT__
  4.  
  5. class TException;
  6.  
  7. #include <Threads.h>
  8. #include "MWException.h"
  9.  
  10. pascal OSErr ThreadCreateNotifyHandler(ThreadID createdThread, long threadCreateRefcon);
  11. pascal OSErr ThreadCreateHandler(ThreadEntryProcPtr threadEntry, void *threadParam, long handlerRefCon, ThreadID *threadMade);
  12.  
  13. class TThreadContext
  14. {
  15. private:
  16.     static long        fCreatedThreads;
  17.     static long        fSleepingThreads;
  18.     
  19. public:
  20.                     TThreadContext(long threadCreateRefcon);
  21.     ~TThreadContext() { --fCreatedThreads; if(fSleeping) --fSleepingThreads; }
  22.     
  23.     void            SwapIn(ThreadID);
  24.     void            SwapOut(ThreadID);
  25.     void            DisposeContext(ThreadID);
  26.  
  27.     long            ThreadCreateRefcon() const { return fThreadCreateRefcon; }
  28.     
  29.     static long        TotalThreads() { return fCreatedThreads; }
  30.     static long        SleepingThreads() { return fSleepingThreads; }
  31.     static long        ActiveThreads() { return TotalThreads() - SleepingThreads(); }
  32.     
  33. private:
  34.  
  35.     ExceptionState    fExceptionStack;
  36.     char            fCatchBuffer[CATCH_BUFSIZE];    // buffer for thrown object
  37.  
  38. #if 0
  39. #if __MWERKS__
  40.     void*            fLocalDestructorChain;
  41. #endif
  42.     TException*        fExceptionStack;
  43. #endif
  44.  
  45.     const long        fThreadCreateRefcon;
  46.     Boolean            fSleeping;
  47. };
  48.  
  49. #endif
  50.